<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Kills a specific cursor on the server</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="mongoclient.getwriteconcern.html">« MongoClient::getWriteConcern</a></li>
      <li style="float: right;"><a href="mongoclient.listdbs.html">MongoClient::listDBs »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.mongoclient.html">MongoClient</a></li>
    <li>Kills a specific cursor on the server</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="mongoclient.killcursor" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoClient::killCursor</h1>
  <p class="verinfo">(PECL mongo &gt;=1.5.0)</p><p class="refpurpose"><span class="refname">MongoClient::killCursor</span> &mdash; <span class="dc-title">Kills a specific cursor on the server</span></p>

 </div>

 <div id="mongoclient.killcursor-soft-deprecation-notice" class="soft-deprecation-notice">
  <p class="para">This extension that defines this method
is deprecated. Instead, the <a href="" class="link">MongoDB</a> extension should be used.
There is no equivalent for this method in the new extension.</p>
 </div>

 <div class="refsect1 description" id="refsect1-mongoclient.killcursor-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>MongoClient::killCursor</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$server_hash</code></span>, <span class="methodparam"><span class="type"><span class="type">int</span>|<span class="type"><a href="class.mongoint64.html" class="type MongoInt64">MongoInt64</a></span></span> <code class="parameter">$id</code></span>): <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   In certain situations it might be needed to kill a cursor on the server.
   Usually cursors time out after 10 minutes of inactivity, but it is possible
   to create an immortal cursor with
   <span class="methodname"><a href="mongocursor.immortal.html" class="methodname">MongoCursor::immortal()</a></span> that never times out. In
   order to be able to kill such an immortal cursor, you can call this
   method with the information supplied by
   <span class="methodname"><a href="mongocursor.info.html" class="methodname">MongoCursor::info()</a></span>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-mongoclient.killcursor-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    
     <dt>

      <code class="parameter">server_hash</code>
     </dt>

     <dd>

      <p class="para">
       The server hash that has the cursor. This can be obtained through
       <span class="methodname"><a href="mongocursor.info.html" class="methodname">MongoCursor::info()</a></span>.
      </p>
     </dd>

    
    
     <dt>

      <code class="parameter">id</code>
     </dt>

     <dd>

      <p class="para">
       The ID of the cursor to kill. You can either supply an <span class="type">int</span>
       containing the 64 bit cursor ID, or an object of the
       <a href="class.mongoint64.html" class="classname">MongoInt64</a> class. The latter is necessary on 32
       bit platforms (and Windows).
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongoclient.killcursor-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns <strong><code>true</code></strong> if the method attempted to kill a cursor, and <strong><code>false</code></strong> if
   there was something wrong with the arguments (such as a wrong
   <code class="parameter">server_hash</code>). The return status does <em class="emphasis">not
   reflect</em> where the cursor was actually killed as the server does
   not provide that information.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-mongoclient.killcursor-errors">
  <h3 class="title">Errors/Exceptions</h3>
  <p class="para">
   This method displays a warning if the supplied
   <code class="parameter">server_hash</code> does not match up with an existing
   connection. No attempt to kill a cursor is attempted in that case either.
  </p>
 </div>


 <div class="refsect1 examples" id="mongo.mongoclient.killcursor.examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="example-59">
   <p><strong>Example #1 <span class="function"><strong>MongoClient::killCursor()</strong></span> example</strong></p>
   <div class="example-contents"><p>
    This example shows how to connect, do a query, obtain the cursor
    information and then kill the cursor.
   </p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$m&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoClient</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$c&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$m</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">testdb</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">collection</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$cursor&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$c</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">find</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$cursor</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">next</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">//&nbsp;Now&nbsp;the&nbsp;cursor&nbsp;is&nbsp;valid,&nbsp;so&nbsp;we&nbsp;can&nbsp;get&nbsp;the&nbsp;hash&nbsp;and&nbsp;ID&nbsp;out:<br /></span><span style="color: #0000BB">$info&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$cursor</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">info</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">//&nbsp;Kill&nbsp;the&nbsp;cursor<br /></span><span style="color: #0000BB">MongoClient</span><span style="color: #007700">::</span><span style="color: #0000BB">killCursor</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$info</span><span style="color: #007700">[</span><span style="color: #DD0000">'server'</span><span style="color: #007700">],&nbsp;</span><span style="color: #0000BB">$info</span><span style="color: #007700">[</span><span style="color: #DD0000">'id'</span><span style="color: #007700">]&nbsp;);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div>

</div></div></div></body></html>